//
//  HJDBannerOneCell.m
//  JYHospital
//
//  Created by 胡金东 on 16/5/30.
//  Copyright © 2016年 胡金东. All rights reserved.
//

#import "HJDBannerOneCell.h"

@implementation HJDBannerOneCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.ImageV = [[UIImageView alloc]initWithFrame:CGRectZero];
        [self.ImageV setRadius:20 borderWith:0 borderColor:nil];
        [self addSubview:self.ImageV];
        
        self.name = [[UILabel alloc]initWithFrame:CGRectZero];
        self.name.textColor = [UIColor getColorWithHexNumber:@"323232"];
        self.name.font = [UIFont systemFontOfSize:19];
        [self addSubview:self.name];
        
        self.departments = [[UILabel alloc]initWithFrame:CGRectZero];
        self.departments.textColor = [UIColor getColorWithHexNumber:@"323232"];
        self.departments.font = [UIFont systemFontOfSize:19];
        [self addSubview:self.departments];
        
        self.post = [[UILabel alloc]initWithFrame:CGRectZero];
        self.post.textColor = [UIColor getColorWithHexNumber:@"323232"];
        self.post.font = [UIFont systemFontOfSize:14];
        [self addSubview:self.post];
        
        self.introduce = [[UILabel alloc]initWithFrame:CGRectZero];
        self.introduce.textColor = [UIColor getColorWithHexNumber:@"848484"];
        self.introduce.font = [UIFont systemFontOfSize:14];
        self.introduce.numberOfLines = 0;
        [self addSubview:self.introduce];
        
        self.year = [[UILabel alloc]initWithFrame:CGRectZero];
        self.year.textColor = [UIColor getColorWithHexNumber:@"FF92A2"];
        self.year.font = [UIFont systemFontOfSize:12];
        [self addSubview:self.year];
        
        self.yearCon = [[UILabel alloc]initWithFrame:CGRectZero];
        self.yearCon.textColor = [UIColor getColorWithHexNumber:@"323232"];
        self.yearCon.font = [UIFont systemFontOfSize:12];
        self.yearCon.text = @"年工作经验";
        [self addSubview:self.yearCon];
    }
    return self;
}

-(void)layoutSubviews
{
    CGFloat ImageVX = HJDHorizontalMargin/2;
    CGFloat ImageVY = HJDVerticalMargin;
    CGFloat ImageVW = 40;
    CGFloat ImageVH = 40;
    self.ImageV.frame = CGRectMake(ImageVX, ImageVY, ImageVW, ImageVH);
    
    CGFloat nameX = CGRectGetMaxX(self.ImageV.frame)+HJDHorizontalMargin/2;
    CGFloat nameY = ImageVY;
    CGSize nameSize = [_name.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:self.name.font,NSFontAttributeName, nil]];
    self.name.frame = (CGRect){{nameX,nameY},nameSize};
    
    CGFloat departmentsX = CGRectGetMaxX(self.name.frame)+HJDHorizontalMargin/2;
    CGFloat departmentsY = ImageVY;
    CGSize departmentsSize = [_departments.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:self.departments.font,NSFontAttributeName, nil]];
    self.departments.frame = (CGRect){{departmentsX,departmentsY},departmentsSize};
    
    CGFloat postX = CGRectGetMaxX(self.departments.frame)+HJDHorizontalMargin/2;
    CGFloat postY = ImageVY;
    CGSize postSize = [_post.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:self.post.font,NSFontAttributeName, nil]];
    self.post.frame = (CGRect){{postX,postY},postSize};
    
    CGFloat introduceX = CGRectGetMaxX(self.ImageV.frame) + HJDHorizontalMargin/2 ;
    CGFloat introduceY = CGRectGetMaxY(self.name.frame) + 5;
    CGFloat introduceW = HJDWidth - HJDHorizontalMargin * 2 - ImageVW ;
    CGRect introduceRect = [_introduce.text boundingRectWithSize:CGSizeMake(introduceW, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObjectsAndKeys:self.introduce.font,NSFontAttributeName, nil] context:nil];
    self.introduce.frame = (CGRect){{introduceX,introduceY},introduceRect.size};
    
    CGFloat yearX = CGRectGetMaxX(self.ImageV.frame)+HJDHorizontalMargin/2;
    CGFloat yearY = CGRectGetMaxY(self.introduce.frame)+ HJDVerticalMargin;
    CGSize yearSize = [_year.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:self.year.font,NSFontAttributeName, nil]];
    self.year.frame = (CGRect){{yearX,yearY},yearSize};
    
    CGFloat yearConX = CGRectGetMaxX(self.year.frame);
    CGFloat yearConY = yearY;
    CGSize yearConSize = [_yearCon.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:self.yearCon.font,NSFontAttributeName, nil]];
    
    self.yearCon.frame = (CGRect){{yearConX,yearConY},yearConSize};


    

    
    


}

@end
